﻿$(window).load(function(){  
   $(".loading").fadeOut()
})  
$(function () {
	findtable01();//总指标
	function findtable01(){
		var taskWork = $('#tableindex_select_type option:selected').text();//选中的文本
		$.ajax({
			type: 'post',
			data: {taskWork:taskWork},
			url: "/panel/findSum",
			dataType:"json",
			success: function (data) {
				$("#hours").html(data.data.hours)
				$("#volume").html(data.data.volume)
				$("#nums").html(data.data.nums)
				$("#weights").html(data.data.weights)
			}
		});
	}
	$("#tableindex_select_type").change(function(){
		findtable01();
	});
	
	findtable1();//项目日作业排名
	function findtable1(){
		$("#table1_tbody>tr:first").nextAll().remove();
		var mode = $('#table1_select option:selected').text();//选中的文本
		var taskWork = $('#table1_select_type option:selected').text();//选中的文本
		$("#table1_tbody_settlementMode").html(mode)
		$.ajax({
			type: 'post',
			data: {"settlementMode":mode,"taskWork":taskWork},
			url: "/panel/panelOperateDay",
			dataType:"json",
			success: function (data) {
				var html = '';
				var list = data.data
				if (list.length>0) {
					for (var i = 0; i < list.length ; i++) {
						html+= '<tr>'+
									'<td><span>'+ (i+1) +'</span></td>'+
									'<td>'+ list[i].operateName +'</td>'+
									'<td>'+ list[i].nums +'</td>'+
								'</tr>';
					}
				}
				$("#table1_tr").after(html);
			}
		});
	}
	$("#table1_select").change(function(){
		findtable1();
	});
	$("#table1_select_type").change(function(){
		findtable1();
	});
	
	findtable2();//项目月作业排名
	function findtable2(){
		$("#table2_tbody>tr:first").nextAll().remove();
		var mode = $('#table2_select option:selected').text();//选中的文本
		var taskWork = $('#table2_select_type option:selected').text();//选中的文本
		$("#table2_tbody_settlementMode").html(mode)
		$.ajax({
			type: 'post',
			data: {"settlementMode":mode,"taskWork":taskWork},
			url: "/panel/panelOperateMonth",
			dataType:"json",
			success: function (data) {
				var html = '';
				var list = data.data
				if (list.length>0) {
					for (var i = 0; i < list.length ; i++) {
						html+= '<tr>'+
									'<td><span>'+ (i+1) +'</span></td>'+
									'<td>'+ list[i].operateName +'</td>'+
									'<td>'+ list[i].nums +'</td>'+
								'</tr>';
					}
				}
				$("#table2_tr").after(html);
			}
		});
	}
	$("#table2_select").change(function(){
		findtable2();
	});
	$("#table2_select_type").change(function(){
		findtable2();
	});
	
	
	findtable4();
	function findtable4(){
		$.ajax({
			type: 'post',
			data: {},
			url: "/panel/findlimit9task",
			dataType:"json",
			success: function (data) {
				var html = '';
				var list = data.data
				if (list.length>0) {
					for (var i = 0; i < list.length ; i++) {
						if(list[i].settlementMode == '体积'){
							html+= '<li><p><span>'+list[i].abbreviation+'</span><span>'+list[i].userName+'</span><span>'+list[i].volume+'m3</span><span>'+list[i].hours+'h</span></p></li>'
						}
						if(list[i].settlementMode == '数量'){
							html+= '<li><p><span>'+list[i].abbreviation+'</span><span>'+list[i].userName+'</span><span>'+list[i].nums+'件</span><span>'+list[i].hours+'h</span></p></li>'
						}
						if(list[i].settlementMode == '重量'){
							html+= '<li><p><span>'+list[i].abbreviation+'</span><span>'+list[i].userName+'</span><span>'+list[i].weights+'t</span><span>'+list[i].hours+'h</span></p></li>'
						}
						if(list[i].settlementMode == '工时'){
							html+= '<li><p><span>'+list[i].abbreviation+'</span><span>'+list[i].userName+'</span><span>'+list[i].hours+'h</span><span>'+list[i].hours+'h</span></p></li>'
						}
					}
				}
				$("#wrap-ul").html(html);
			}
		});
	}
	
	
    echarts_1();
    function echarts_1() {
		var mode = $('#table6_select option:selected').text();//选中的文本
		$.ajax({
			type: 'post',
			data: {"settlementMode":mode},
			url: "/panel/findSumtaskWork",
			dataType:"json",
			success: function (data) {
				var list = data.data
				if (list.length>0) {
					let arr = []
					for (var i = 0; i < list.length ; i++) {
						let obj = {}
						obj.name = list[i].taskWork
						if(mode == '工时'){
							obj.value = list[i].hours
						}
						if(mode == '体积'){
							obj.value = list[i].volume
						}
						if(mode == '数量'){
							obj.value = list[i].nums
						}
						if(mode == '重量'){
							obj.value = list[i].weights
						}
						arr.push(obj)
					}
					
			        // 基于准备好的dom，初始化echarts实例
			        var myChart = echarts.init(document.getElementById('echart1'));
			        option = {
			            tooltip : {
			                trigger: 'item',
			                formatter: "{b} : {c} ({d}%)"
			            },
						toolbox: {
							show: true,
							feature: {
								mark: {show: true},
								dataView: {show: true, readOnly: false},
								restore: {show: true},
								saveAsImage: {show: true}
							}
						},
			            legend: {
			                right:0,
			                top:30,
			                height:160,
			                itemWidth:10,
			                itemHeight:10,
			                itemGap:10,
			                textStyle:{
			                    color: 'rgba(255,255,255,.6)',
			                    fontSize:12
			                },
			                orient:'vertical',
			            },
			           calculable : true,
			            series : [
			                {
			                    name:' ',
								color: ['#62c98d', '#2f89cf', '#4cb9cf', '#53b666', '#62c98d', '#205acf', '#c9c862', '#c98b62', '#c962b9', '#7562c9','#c96262','#c25775','#00b7be'],	
			                    type:'pie',
			                    radius : [30, 70],
			                    center : ['35%', '50%'],
			                    roseType : 'radius',
			                    label: {
			                        normal: {
			                            show: true
			                        },
			                        emphasis: {
			                            show: true
			                        }
			                    },
			
			                    lableLine: {
			                        normal: {
			                            show: true
			                        },
			                        emphasis: {
			                            show: true
			                        }
			                    },
			
			                    data:arr
			                },
			            ]
			        };
			
			        // 使用刚指定的配置项和数据显示图表。
			        myChart.setOption(option);
			        window.addEventListener("resize",function(){
			            myChart.resize();
			        });
					// 调用本工具接口
					tools.loopShowTooltip(myChart, option, {
					    loopSeries: true,
						interval:2500
					});
				}
			}
		});
    }
	$("#table6_select").change(function(){
		echarts_1();
	});

	echarts_2();
	function echarts_2() {
		$.ajax({
			type: 'post',
			data: {},
			url: "/panel/sumPeoples",
			dataType:"json",
			success: function (data) {
				var html = '';
				var list = data.data
				if (list.length>0) {
					let arr = []
					for (var i = 0; i < list.length ; i++) {
						let obj = {}
						obj.value = list[i].peoples
						obj.name = list[i].operateName
						arr.push(obj)
					}
					var arrlength = arr.length
					for (var i = 0; i < arrlength ; i++) {
						let obj = {}
						obj.value = 0
						obj.name = ""
						let obj1 = {}
						obj1.show = false
						obj.label = obj1
						let obj2 = {}
						obj2.show = false
						obj.labelLine = obj2
						arr.push(obj)
					}
		
			        // 基于准备好的dom，初始化echarts实例
			        var myChart = echarts.init(document.getElementById('echart2'));
			
			        option = {
			            tooltip: {
			                trigger: 'item',
			               formatter: "{b} : {c} ({d}%)"
			            },
						toolbox: {
							show: true,
							feature: {
								mark: {show: true},
								dataView: {show: true, readOnly: false},
								restore: {show: true},
								saveAsImage: {show: true}
							}
						},
			            legend: {
						
							top:'15%',
			                icon: 'circle',
			                textStyle: {
			                    color: 'rgba(255,255,255,.6)',
			                }
			            },
			            calculable: true,
			            series: [{
			                name: '',
							color: ['#62c98d', '#2f89cf', '#4cb9cf', '#53b666', '#62c98d', '#205acf', '#c9c862', '#c98b62', '#c962b9','#c96262'],	
			                type: 'pie',
			                //起始角度，支持范围[0, 360]
			                startAngle: 0,
			                //饼图的半径，数组的第一项是内半径，第二项是外半径
			                radius: [51, 100],
			                //支持设置成百分比，设置成百分比时第一项是相对于容器宽度，第二项是相对于容器高度
			                center: ['50%', '45%'],
							
			                //是否展示成南丁格尔图，通过半径区分数据大小。可选择两种模式：
			                // 'radius' 面积展现数据的百分比，半径展现数据的大小。
			                //  'area' 所有扇区面积相同，仅通过半径展现数据大小
			                roseType: 'area',
			                //是否启用防止标签重叠策略，默认开启，圆环图这个例子中需要强制所有标签放在中心位置，可以将该值设为 false。
			                avoidLabelOverlap: false,
			                label: {
			                    normal: {
			                        show: true,
			                      //  formatter: '{c}辆'
			                    },
			                    emphasis: {
			                        show: true
			                    }
			                },
			                labelLine: {
			                    normal: {
			                        show: true,
			                        length2: 1,
			                    },
			                    emphasis: {
			                        show: true
			                    }
			                },
			                data: arr
			            }]
			        };
			
			        // 使用刚指定的配置项和数据显示图表。
			        myChart.setOption(option);
			        window.addEventListener("resize",function(){
			            myChart.resize();
			        });
				}
			}
		});
		
    }

	echarts_3();
	function echarts_3() {
		var mode = $('#table4_select option:selected').text();//选中的文本
		var taskWork = $('#table4_select_type option:selected').text();//选中的文本
		$.ajax({
			type: 'post',
			data: {"settlementMode":mode,"taskWork":taskWork},
			url: "/panel/findshixiaopaiming",
			dataType:"json",
			success: function (data) {
				var list = data.data
				if (list.length>0) {
					list.sort(function(a,b){
						return b.prescription - a.prescription;
					})
					let arr1 = []
					let arr2 = []
					for (var i = 0; i < list.length ; i++) {
						arr1.push(list[i].operateName)
						arr2.push(list[i].prescription)
					}
		
			        // 基于准备好的dom，初始化echarts实例
			        var myChart = echarts.init(document.getElementById('echart3'));
			
			        option = {
						tooltip: {
							trigger: 'axis',
							axisPointer: {
								lineStyle: {
									color: '#57617B'
								}
							}
						},
						toolbox: {
							show: true,
							feature: {
								mark: {show: true},
								dataView: {show: true, readOnly: false},
								restore: {show: true},
								saveAsImage: {show: true}
							}
						},
						grid: {
							left: '0',
							right: '20',
							top:'10',
							bottom: '15',
							containLabel: true
						},
						xAxis: [{
							type: 'category',
							boundaryGap: false,
							axisLabel: {
								show: true,
								textStyle: {
		                            color: 'rgba(255,255,255,.6)'
		                        },
								interval:0,
								formatter:function(value){
									return value.split("").join("\n")
								}
							},
							axisLine: {
								lineStyle: {
									color: 'rgba(255,255,255,.1)'
								}
							},
							data: arr1
						}],
						yAxis: [{
							axisLabel: {
								show: true,
								textStyle: {
					                           color: 'rgba(255,255,255,.6)'
					                        }
							},
							axisLine: {
								lineStyle: {
									color: 'rgba(255,255,255,.1)'
								}
							},
							splitLine: {
								lineStyle: {
									color: 'rgba(255,255,255,.1)'
								}
							}
						}],
						series: [{
							type: 'line',
							smooth: true,
							symbol: 'circle',
							symbolSize: 5,
							showSymbol: false,
							lineStyle: {
								normal: {
									width: 2
								}
							},
							areaStyle: {
								normal: {
									color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
										offset: 0,
										color: 'rgba(24, 163, 64, 0.3)'
									}, {
										offset: 0.8,
										color: 'rgba(24, 163, 64, 0)'
									}], false),
									shadowColor: 'rgba(0, 0, 0, 0.1)',
									shadowBlur: 10
								}
							},
							itemStyle: {
								normal: {
									color: '#cdba00',
									borderColor: 'rgba(137,189,2,0.27)',
									borderWidth: 12
								}
							},
							data: arr2
						}]
					};
			        // 使用刚指定的配置项和数据显示图表。
			        myChart.setOption(option);
			        window.addEventListener("resize",function(){
			            myChart.resize();
			        });
					// 调用本工具接口
					tools.loopShowTooltip(myChart, option, {
					    loopSeries: true,
						interval:2500
					});
				}
			}
		});
    }
	$("#table4_select").change(function(){
		echarts_3();
	});
	$("#table4_select_type").change(function(){
		echarts_3();
	});

	echarts_4();
	function echarts_4() {
		var mode = $('#table5_select option:selected').text();//选中的文本
		var taskWork = $('#table5_select_type option:selected').text();//选中的文本
		$.ajax({
			type: 'post',
			data: {"settlementMode":mode,"taskWork":taskWork},
			url: "/panel/panelOperateMonthDuibi",
			dataType:"json",
			success: function (data) {
				var list = data.data
				if (list.length>0) {
					let SY = list[0].v6
					let BY = list[0].v5
					let arr1 = []
					let arr2 = []
					let arr3 = []
					if(mode == "工时"){
						list.sort(function(a,b){
							return b.v2 - a.v2;
						})
					}
					if(mode == "体积"){
						list.sort(function(a,b){
							return b.v3 - a.v3;
						})
					}
					if(mode == "数量"){
						list.sort(function(a,b){
							return b.v1 - a.v1;
						})
					}
					if(mode == "重量"){
						list.sort(function(a,b){
							return b.v4 - a.v4;
						})
					}
					for (var i = 0; i < list.length ; i++) {
						arr1.push(list[i].abbreviation)
						if(mode == "工时"){
							arr2.push(list[i].hours)
							arr3.push(list[i].v2)
						}
						if(mode == "体积"){
							arr2.push(list[i].volume)
							arr3.push(list[i].v3)
						}
						if(mode == "数量"){
							arr2.push(list[i].nums)
							arr3.push(list[i].v1)
						}
						if(mode == "重量"){
							arr2.push(list[i].weights)
							arr3.push(list[i].v4)
						}
						
					}
			        // 基于准备好的dom，初始化echarts实例
			        var myChart = echarts.init(document.getElementById('echart4'));
					option = {
					   	tooltip: {
							trigger: 'axis',
							axisPointer: {
								lineStyle: {
									color: '#57617B'
								}
							}
						},
						toolbox: {
							show: true,
							feature: {
								mark: {show: true},
								dataView: {show: true, readOnly: false},
								restore: {show: true},
								saveAsImage: {show: true}
							}
						},
					    "legend": {
					      "top": "0%",
					      "textStyle": {
					       "color": "rgba(255,255,255,0.9)"//图例文字
					      }
					    },
						
					    "xAxis": [{
							"type": "category",
					        data: arr1,
							axisLine: { lineStyle: {color: "rgba(255,255,255,.1)"}},
					        axisLabel: {
								textStyle: {
									color: "rgba(255,255,255,.6)"
								},
								interval:0,
								formatter:function(value){
									return value.split("").join("\n")
								}
					        },
				        }],
						yAxis: [{
							axisLabel: {
								show: true,
								textStyle: {
					                           color: 'rgba(255,255,255,.6)'
					                        }
							},
							axisLine: {
								lineStyle: {
									color: 'rgba(255,255,255,.1)'
								}
							},
							splitLine: {
								lineStyle: {
									color: 'rgba(255,255,255,.1)'
								}
							}
						}],
					    "grid": {
					      "top": "10%",
							"right":"30",
							"bottom":"55",
							"left":"50",
					    },
					    "series": [
					      {
					        "name": SY+"月",
							  
					        "type": "bar",
					        "data": arr3,
					        "barWidth": "auto",
					        "itemStyle": {
					          "normal": {
					            "color": {
					              "type": "linear",
					              "x": 0,
					              "y": 0,
					              "x2": 0,
					              "y2": 1,
					              "colorStops": [
					                {
					                  "offset": 0,
					                  "color": "#609db8"
					                },
					                
					                {
					                  "offset": 1,
					                  "color": "#609db8"
					                }
					              ],
					              "globalCoord": false
					            }
					          }
					        }
					      },
					      {
					        "name": BY+"月",
					        "type": "bar",
					        "data": arr2,
					        "barWidth": "auto",
							
					        "itemStyle": {
					          "normal": {
					            "color": {
					              "type": "linear",
					              "x": 0,
					              "y": 0,
					              "x2": 0,
					              "y2": 1,
					              "colorStops": [
					                {
					                  "offset": 0,
					                  "color": "#66b8a7"
					                },
					                {
					                  "offset": 1,
					                  "color": "#66b8a7"
					                }
					              ],
					              "globalCoord": false
					            }
					          }
					        },
					        "barGap": "0"
					      }
					    ]
					};
			        // 使用刚指定的配置项和数据显示图表。
			        myChart.setOption(option);
			        window.addEventListener("resize",function(){
			            myChart.resize();
			        });
					// 调用本工具接口
					tools.loopShowTooltip(myChart, option, {
					    loopSeries: true,
						interval:2500
					});
				}
			}
		});
    }
	$("#table5_select").change(function(){
		echarts_4();
	});
	$("#table5_select_type").change(function(){
		echarts_4();
	});
	
	findtable3();
	function findtable3(){
		$("#table3_tbody>tr:first").nextAll().remove();
		var mode = $('#table3_select option:selected').text();//选中的文本
		var taskWork = $('#table3_select_type option:selected').text();//选中的文本
		$("#table3_tbody_settlementMode").html(mode)
		$.ajax({
			type: 'post',
			data: {"settlementMode":mode,"taskWork":taskWork},
			url: "/panel/sumGongrenMonth",
			dataType:"json",
			success: function (data) {
				var html = '';
				var list = data.data
				if (list.length>0) {
					for (var i = 0; i < list.length ; i++) {
						html+= '<tr>'+
									'<td><span>'+ (i+1) +'</span></td>'+
									'<td>'+ list[i].v1 +'</td>'+
									'<td>'+ list[i].userName +'</td>'+
									'<td>'+ list[i].nums +'</td>'+
								'</tr>';
					}
				}
				$("#table3_tr").after(html);
			}
		});
	}
	$("#table3_select").change(function(){
		findtable3();
	});
	$("#table3_select_type").change(function(){
		findtable3();
	});
	
})



		
		
		


		









